package org.zjx.message;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.zjx.action.ActionType;
import org.zjx.action.IAction;

@EqualsAndHashCode(callSuper = true)
@Data
@JSONType(typeName = "ACTION")
@NoArgsConstructor
public class ActionMessage extends Message {
    private ActionType actionType;
    private String data;

    public ActionMessage(IAction action) {
        this.actionType = action.getActionType();
        setType(MessageType.ACTION);
        data = action.toJson().toString();
        setTimestamp(System.currentTimeMillis());
    }
}
